﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;


namespace EvidenceManagement.Data.Common
{
    public interface IDataRepository
    {
        /// <summary>
        /// Creates a database command.
        /// </summary>
        /// <param name="commandType">Type of the command specifying how the command string will be intepreted.</param>
        /// <param name="commandText">The command string to execute.</param>
        /// <returns></returns>
        DbCommand CreateCommand(CommandType commandType, string commandText);
        /// <summary>
        /// Creates a transaction against a data source.
        /// </summary>
        /// <returns>DbTransaction</returns>
        DbTransaction CreateTransaction();
        /// <summary>
        /// Creates a transaction against a data source
        /// </summary>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <returns></returns>
        DbTransaction CreateTransaction(IsolationLevel isolationLevel);
        /// <summary>
        /// Retrieves parameter information from the stored procedure specified in the DbCommand and populates the Parameters collection of the specified DbCommand object.
        /// </summary>
        /// <param name="command">The DbCommand referencing the stored procedure from which the parameter information is to be derived.
        /// The derived parameters are added to the Parameters collection of the DbCommand.</param>
        /// <returns></returns>
        void DiscoverDbCommandParameters(DbCommand command);
        /// <summary>
        /// Adds command parameter to the specified database command's parameter collection.
        /// </summary>
        /// <param name="command">The database command to add a data parameter to.</param>
        /// <param name="name">The data parameter name.</param>
        /// <param name="dataType">The data type of the data parameter.</param>
        /// <param name="value">The value to assign to the data parameter.</param>
        /// <returns></returns>
        void AddCommandParameter(DbCommand command, string name, DbType dataType, object value);
        /// <summary>
        /// Adds command parameter to the specified database command's parameter collection.
        /// </summary>
        /// <param name="command">The database command to add a data parameter to.</param>
        /// <param name="name">The data parameter name.</param>
        /// <param name="dataType">The data type of the data parameter.</param>
        /// <param name="value">The value to assign to the data parameter.</param>
        /// <param name="parameterDirection">The data parameter direction.</param>
        /// <returns></returns>
        void AddCommandParameter(DbCommand command, string name, DbType dataType, object value, ParameterDirection parameterDirection);
        /// <summary>
        /// Adds command parameter to the specified database command's parameter collection.
        /// </summary>
        /// <param name="command">The database command to add a data parameter to.</param>
        /// <param name="name">The data parameter name.</param>
        /// <param name="dataType">The data type of the data parameter.</param>
        /// <param name="value">The value to assign to the data parameter.</param>
        /// <param name="parameterDirection">The data parameter direction.</param>
        /// <param name="size">The size fo the data parameter.</param>
        /// <returns></returns>
        void AddCommandParameter(DbCommand command, string name, DbType dataType, object value, ParameterDirection parameterDirection, int size);
        /// <summary>
        /// Executes a database command and builds an IDataReader.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <returns>IDataReader resultset.</returns>
        IDataReader ExecuteDataReader(DbCommand command);
        /// <summary>
        /// Executes a database command and builds an IDataReader.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <param name="transaction">The transaction to be performed against the datasource.</param>
        /// <returns>IDataReader resultset.</returns>
        IDataReader ExecuteDataReader(DbCommand command, DbTransaction transaction);
        /// <summary>
        ///  Executes the database command, and returns the first column of the first row in the
        ///  resultset returned by the query. Extra columns or rows are ignored.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <returns>The first column of the first row in the resultset.</returns>
        Object ExecuteScalar(DbCommand command);
        /// <summary>
        ///  Executes the database command in a transactional scope, and returns the first column of the first row in the
        ///  resultset returned by the query. Extra columns or rows are ignored.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <param name="transaction">The transaction to be performed against the datasource.</param>
        /// <returns>The first column of the first row in the resultset.</returns>
        Object ExecuteScalar(DbCommand command,DbTransaction transaction);
        /// <summary>
        /// Executes the database command against the data source, and returns the number of rows affected.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <returns>Number of rows affected</returns>
        int ExecuteNonQuery(DbCommand command);
        /// <summary>
        /// Executes the database command in a transactional scope against the data source, and returns the number of rows affected.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <param name="transaction">The transaction to be performed against the datasource.</param>
        /// <returns>Number of rows affected</returns>
        int ExecuteNonQuery(DbCommand command,DbTransaction transaction);        
        /// <summary>
        /// Executes a database command and returns a DataSet.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <returns>DataSet</returns>
        DataSet ExecuteDataSet(DbCommand command);
        /// <summary>
        /// Executes a database command and returns a DataSet.
        /// </summary>
        /// <param name="command">The database command to execute.</param>
        /// <param name="transaction">The transaction to be performed against the datasource.</param>
        /// <returns>DataSet</returns>
        DataSet ExecuteDataSet(DbCommand command, DbTransaction transaction);
    }
} 
